package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	resp, _ := http.Get("https://www.cnblogs.com/")
	defer resp.Body.Close()

	fmt.Println(resp.Status) // 200 OK
	fmt.Println(resp.Header) // 响应头

	buf := make([]byte, 1024)
	for {
		// 接收服务端信息
		n, err := resp.Body.Read(buf)
		if err != nil || err == io.EOF {
			fmt.Println(err)
			return
		} else {
			res := string(buf[:n])
			fmt.Println(res)
		}
	}
}
